
import org.apache.commons.beanutils.PropertyUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;

@Service
public class FmsMaterialConfigServiceImpl implements FmsMaterialConfigService  {

    @Resource
    private FmsMaterialConfigMapper fmsMaterialConfigMapper;

    /**
     * 获取 FmsMaterialConfig 分页列表
     */
    @Transactional
    public IPage getFmsMaterialConfigPagination( PaginationVo paginationVo, FmsMaterialConfigQuery fmsMaterialConfigQuery ) throws Exception {

        IPage page = new Page( paginationVo.getPageIndex(), paginationVo.getPageSize() );
        LambdaQueryWrapper<FmsMaterialConfigEntity> lqs = new LambdaQueryWrapper();
        fmsMaterialConfigMapper.selectPage(page, lqs);

        List<FmsMaterialConfigEntity> record = page.getRecords();
        if( !ObjectUtil.isNotEmptyList(record)){
            return page;
        }
        return null;
    }


    /**
     * 获取 FmsMaterialConfig 所有数据
     *
    */
    @Transactional
    public List<FmsMaterialConfigEntity> getFmsMaterialConfigAllList( FmsMaterialConfigQuery fmsMaterialConfigQuery ) throws Exception {

        LambdaQueryWrapper<FmsMaterialConfigEntity> lqs = new LambdaQueryWrapper();
        List<FmsMaterialConfigEntity> list = fmsMaterialConfigMapper.selectList(lqs);
        return list;
    }


    /**
     * 获取 FmsMaterialConfig 详情
    */
    @Transactional
    public FmsMaterialConfigEntity getFmsMaterialConfigDetail( Long id) throws Exception {

        FmsMaterialConfigEntity fmsMaterialConfig = fmsMaterialConfigMapper.selectById(id);
        return fmsMaterialConfig;
    }


    /**
     * 新增 FmsMaterialConfig
     * */
    @Transactional
    public void addFmsMaterialConfig(FmsMaterialConfigVo fmsMaterialConfigVo) throws Exception {

        FmsMaterialConfigEntity fmsMaterialConfig = new FmsMaterialConfigEntity();
        ReflectionCopy.copyProperties( fmsMaterialConfig, fmsMaterialConfigVo );
        fmsMaterialConfigMapper.insert(fmsMaterialConfig);
        return;
    }


    /**
     * 更新 FmsMaterialConfig
     * */
    @Transactional
    public void updateFmsMaterialConfig( FmsMaterialConfigVo fmsMaterialConfigVo) throws Exception {

        if( fmsMaterialConfigVo.getId() == null ){
            throw GlobalException.gen(10021, "id不存在");
        }
        FmsMaterialConfigEntity fmsMaterialConfig = new FmsMaterialConfigEntity();
        ReflectionCopy.copyProperties( fmsMaterialConfig, fmsMaterialConfigVo );
        fmsMaterialConfigMapper.updateById(fmsMaterialConfig);
        return;
    }

    /**
     * 删除 FmsMaterialConfig
     * */
    @Transactional
    public void batchRemoveFmsMaterialConfig( List<Long> ids ) throws Exception {


        if( !ObjectUtil.isNotEmptyList(ids) ){
            throw GlobalException.gen(10011, "要删除的id不存在");
        }
        fmsMaterialConfigMapper.deleteBatchIds(ids);
    }

}

      